package com.cm.caseManagement.service.impl;

import com.cm.caseManagement.utils.DateUtils;

import com.cm.caseManagement.dao.CmBeforeLitigationMapper;
import com.cm.caseManagement.pojo.entity.CmBeforeLitigation;
import com.cm.caseManagement.service.ICmBeforeLitigationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 诉前Service业务层处理
 *
 * @author ruoyi
 * @date 2025-10-05
 */
@Service
public class CmBeforeLitigationServiceImpl implements ICmBeforeLitigationService
{
    @Autowired
    private CmBeforeLitigationMapper cmBeforeLitigationMapper;

    /**
     * 查询诉前
     *
     * @param id 诉前主键
     * @return 诉前
     */
    @Override
    public CmBeforeLitigation selectCmBeforeLitigationById(Long id)
    {
        return cmBeforeLitigationMapper.selectCmBeforeLitigationById(id);
    }

    /**
     * 查询诉前列表
     *
     * @param cmBeforeLitigation 诉前
     * @return 诉前
     */
    @Override
    public List<CmBeforeLitigation> selectCmBeforeLitigationList(CmBeforeLitigation cmBeforeLitigation)
    {
        return cmBeforeLitigationMapper.selectCmBeforeLitigationList(cmBeforeLitigation);
    }

    /**
     * 新增诉前
     *
     * @param cmBeforeLitigation 诉前
     * @return 结果
     */
    @Override
    public int insertCmBeforeLitigation(CmBeforeLitigation cmBeforeLitigation)
    {
        cmBeforeLitigation.setCreateTime(DateUtils.getNowDate());
        return cmBeforeLitigationMapper.insertCmBeforeLitigation(cmBeforeLitigation);
    }

    /**
     * 修改诉前
     *
     * @param cmBeforeLitigation 诉前
     * @return 结果
     */
    @Override
    public int updateCmBeforeLitigation(CmBeforeLitigation cmBeforeLitigation)
    {
        cmBeforeLitigation.setUpdateTime(DateUtils.getNowDate());
        return cmBeforeLitigationMapper.updateCmBeforeLitigation(cmBeforeLitigation);
    }

    /**
     * 批量删除诉前
     *
     * @param ids 需要删除的诉前主键
     * @return 结果
     */
    @Override
    public int deleteCmBeforeLitigationByIds(Long[] ids)
    {
        return cmBeforeLitigationMapper.deleteCmBeforeLitigationByIds(ids);
    }

    /**
     * 删除诉前信息
     *
     * @param id 诉前主键
     * @return 结果
     */
    @Override
    public int deleteCmBeforeLitigationById(Long id)
    {
        return cmBeforeLitigationMapper.deleteCmBeforeLitigationById(id);
    }

    /**
     * 根据案件id查询诉前相关信息
     * @param caseId
     * @return
     */
    @Override
    public CmBeforeLitigation selectCmBeforeLitigationByCaseId(Long caseId) {
        return cmBeforeLitigationMapper.selectCmBeforeLitigationByCaseId(caseId);
    }
}
